﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Revis.VClinicNet.Util.Extensions;

using Revis.VClinicNet.Core.Domain;

namespace Revis.VClinicNet.App.Internal.Tests
{
    internal static class Rich
    {
        private static readonly Random rand = new Random();

        public static Doctor Doctor()
        {
            Doctor doctor = new Doctor(
                rand.Next(5),
                rand.String(5),
                rand.String(5));
            foreach (DayOfWeek day in Enum.GetValues(typeof(DayOfWeek))) {
                WorkTime wt = WorkTime();
                wt.Day = day;
                doctor.SetWorkTime(wt);
            }
            return doctor;
        }

        public static Patient Patient()
        {
            Patient patient = new Patient(
                rand.Next(5),
                Rich.PersonalData(),
                Rich.Doctor());

            int entriesCount = rand.Next(10);
            for (int i = 0; i < entriesCount; i++) {
                patient.Card.Add(
                    new Entry(
                        i,
                        Rich.Doctor(),
                        patient,
                        DateTime.Now,
                        Rich.EntryContent()));
            }

            return patient;
        }

        public static Entry Entry()
        {
            Entry entry = new Entry(
               rand.Next(5),
               Rich.Doctor(),
               new Patient(
                   Rich.PersonalData(), Rich.Doctor()),
               DateTime.Now,
               Rich.EntryContent());

            return entry;
        }


        public static PersonalData PersonalData()
        {
            return new PersonalData(
                rand.String(5),
                rand.String(5),
                rand.NumberString(11),
                Address());
        }

        public static Address Address()
        {
            return new Address(
                rand.String(5),
                rand.NumberString(2),
                rand.NumberString(5),
                rand.String(5),
                rand.String(5),
                rand.NumberString(8));
        }

        public static EntryContent EntryContent()
        {
            return new EntryContent(rand.String(5), rand.String(5), rand.String(5));
        }

        public static WorkTime WorkTime()
        {
            Time begin = new Time(rand.Integer(8, 10), rand.Integer(0, 59));
            Time end = new Time(rand.Integer(14, 18), rand.Integer(0, 59));
            DayOfWeek day = (DayOfWeek)rand.Integer(0, 6);
            return new WorkTime(day, begin, end, rand.String(5), true);
        }

        public static Time Time()
        {
            return new Time(rand.Integer(0, 23), rand.Integer(0, 59));
        }


        public static Visit Visit()
        {
            Visit visit = new Visit(
                Rich.Doctor(),
                Rich.Patient(),
                DateTime.Now);
            return visit;
        }
    }
}
